Tower Defense Game

About This Project

The Tower Defense Game is a 2D tower defense game developed using pygame. The game challenges players to strategically place towers to defend their castle from waves of increasingly powerful enemies that follow a pre-defined path.

It includes various types of towers, each with different damage values, ranges, and attack speeds. Players must manage their resources carefully, choosing when and where to place towers to stop enemies before they reach the castle. The game includes a full settings menu with music control.

The project was developed as a way to learn about game loops, collision detection, object-oriented programming, and real-time user input handling. No third-party game engines were used besides pygame, making this project a useful learning experience in low-level game development.

To make the game easily accessible, I used PyInstaller to package the Python code into a standalone .exe file, allowing anyone to play the game on Windows without needing to install Python or additional libraries. The compiled version of the game is available on the project's GitHub Releases page, making it simple to download and run the latest version.

Note: I changed many of the UI elements and game mechanics, so I recommend downloading and running the latest version of the game from the project's GitHub Releases page.

FAQ and Challenges Faced

Why use pygame?

Pygame is a simple yet powerful Python library for creating 2D games. It gave me full control over rendering, event handling, and collision detection, making it ideal for learning how games work at a fundamental level without the complexity of larger game engines.

How do the towers and enemies interact?

Towers automatically detect and shoot enemies that enter their range. Different towers have different stats, and enemies vary in speed and health, creating a tactical balance. The enemies follow a set path toward the castle, and if they reach it, the player loses health points.

What was the biggest challenge?

Balancing the difficulty was one of the hardest parts. I had to fine-tune enemy spawn rates, tower costs, and attack speeds to create a game that felt progressively harder but not impossible. Another challenge was building a user-friendly interface for placing towers and managing game settings.

What did I learn from this project?

This project taught me how to build a complete game structure using Python, manage multiple sprites and object interactions, and design simple yet functional user interfaces. I also gained experience in structuring a codebase for clarity and maintainability.